// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Requests;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using Elastic.Transport;
using Elastic.Transport.Extensions;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning;

public sealed partial class UpdateModelSnapshotRequestParameters : RequestParameters
{
}

/// <summary>
/// <para>
/// Update a snapshot.
/// Updates certain properties of a snapshot.
/// </para>
/// </summary>
public sealed partial class UpdateModelSnapshotRequest : PlainRequest<UpdateModelSnapshotRequestParameters>
{
	public UpdateModelSnapshotRequest(Elastic.Clients.Elasticsearch.Serverless.Id jobId, Elastic.Clients.Elasticsearch.Serverless.Id snapshotId) : base(r => r.Required("job_id", jobId).Required("snapshot_id", snapshotId))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningUpdateModelSnapshot;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ml.update_model_snapshot";

	/// <summary>
	/// <para>
	/// A description of the model snapshot.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("description")]
	public string? Description { get; set; }

	/// <summary>
	/// <para>
	/// If <c>true</c>, this snapshot will not be deleted during automatic cleanup of
	/// snapshots older than <c>model_snapshot_retention_days</c>. However, this
	/// snapshot will be deleted when the job is deleted.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("retain")]
	public bool? Retain { get; set; }
}

/// <summary>
/// <para>
/// Update a snapshot.
/// Updates certain properties of a snapshot.
/// </para>
/// </summary>
public sealed partial class UpdateModelSnapshotRequestDescriptor : RequestDescriptor<UpdateModelSnapshotRequestDescriptor, UpdateModelSnapshotRequestParameters>
{
	internal UpdateModelSnapshotRequestDescriptor(Action<UpdateModelSnapshotRequestDescriptor> configure) => configure.Invoke(this);

	public UpdateModelSnapshotRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Id jobId, Elastic.Clients.Elasticsearch.Serverless.Id snapshotId) : base(r => r.Required("job_id", jobId).Required("snapshot_id", snapshotId))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningUpdateModelSnapshot;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ml.update_model_snapshot";

	public UpdateModelSnapshotRequestDescriptor JobId(Elastic.Clients.Elasticsearch.Serverless.Id jobId)
	{
		RouteValues.Required("job_id", jobId);
		return Self;
	}

	public UpdateModelSnapshotRequestDescriptor SnapshotId(Elastic.Clients.Elasticsearch.Serverless.Id snapshotId)
	{
		RouteValues.Required("snapshot_id", snapshotId);
		return Self;
	}

	private string? DescriptionValue { get; set; }
	private bool? RetainValue { get; set; }

	/// <summary>
	/// <para>
	/// A description of the model snapshot.
	/// </para>
	/// </summary>
	public UpdateModelSnapshotRequestDescriptor Description(string? description)
	{
		DescriptionValue = description;
		return Self;
	}

	/// <summary>
	/// <para>
	/// If <c>true</c>, this snapshot will not be deleted during automatic cleanup of
	/// snapshots older than <c>model_snapshot_retention_days</c>. However, this
	/// snapshot will be deleted when the job is deleted.
	/// </para>
	/// </summary>
	public UpdateModelSnapshotRequestDescriptor Retain(bool? retain = true)
	{
		RetainValue = retain;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (!string.IsNullOrEmpty(DescriptionValue))
		{
			writer.WritePropertyName("description");
			writer.WriteStringValue(DescriptionValue);
		}

		if (RetainValue.HasValue)
		{
			writer.WritePropertyName("retain");
			writer.WriteBooleanValue(RetainValue.Value);
		}

		writer.WriteEndObject();
	}
}